
---@class CustomPatrolEyesTrigger:TriggerBase
CustomPatrolEyesTrigger = class(TriggerBase)

function CustomPatrolEyesTrigger:IsTrigger()
    ---巡逻才生效
    if not self.agent.agentState:Get(ECustomStateKey.Find_target) then
        ---@type UnityEngine.Transform
        self._self = self:GetGameData(ECustomDataName.SelfTrans);
        ---@type UnityEngine.Transform
        self._enemy = self:GetGameData(ECustomDataName.TargetTrans);
        if self._self == nil or self._enemy == nil then
            return false;
        end
        if CS.UnityEngine.Vector3.Distance(self._enemy.position, self._self.position) < 8 then
            local dirToEnemy = (self._enemy.position- self._self.position).normalized;
            if CS.UnityEngine.Vector3.Angle(self._self.position, dirToEnemy) < 60 then
                return true;
            end
        end
    end
    return false;
end

function CustomPatrolEyesTrigger:InitEffects()
    local state = State.new();
    state:Set(ECustomStateKey.Find_target,true);
    return state;
end